##### Figure 1 #####

# Note - Estimates drawn from "1992-1996 Analysis File"

# Ideological Therms (1992) on Values (1996)
model1Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .0775946,
                          SE = .0482537,
                          Domain = "Ideological Groups")
# Values (1992) on Ideological Therms (1996)
model2Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .0857931,
                          SE = .0427,
                          Domain = "Ideological Groups")
# Party Therms (1992) on Values (1996)
model3Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .0628057,
                          SE = .0439806,
                          Domain = "Partisan Groups")
# Values (1992) on Party Therms (1996)
model4Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .1181193,
                          SE = .0442967,
                          Domain = "Partisan Groups")
# Candidate Therms (1992) on Values (1996)
model5Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .0295941,
                          SE = .0428973,
                          Domain = "Presidential Candidates")
# Values (1992) on Candidate Therms (1996)
model6Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .0500962,
                          SE = .0464675,
                          Domain = "Presidential Candidates")

allModelFrame1 <- data.frame(rbind(model2Frame,model1Frame,model4Frame,model3Frame,model6Frame,model5Frame)) 

# Generate Plot
library(ggplot2)

interval2 <- -qnorm((1-0.95)/2) # set 95% CI

fig1 <- ggplot(allModelFrame1, aes(x = Domain, y = Coefficient, shape =  Variable))

fig1 <- fig1 + geom_hline(yintercept = 0, colour = gray(1/2), lty = 2)

fig1 <- fig1 + geom_pointrange(aes(x = Domain, y = Coefficient, ymin = Coefficient - SE*interval2, 
                                 ymax = Coefficient + SE*interval2), lwd = 1/2, position = position_dodge(width = 1/2))

fig1 <- fig1 + scale_shape_manual(name = "Lagged Variable", 
                                values = c(0,15)) 

fig1 <- fig1 + theme_bw() + theme(text=element_text(face="bold", size=12)) +
  theme(axis.title.x = element_blank()) + theme(legend.position="bottom")
fig1 <- fig1

fig1 <- fig1 + scale_y_continuous(breaks=seq(-.10, .25, .05),
                                limits=c(-.10, .25))

fig1


##### Figure 2 #####

# Note - Estimates drawn from "2016-2020 Analysis File"

# Ideological Therms (2016) on Values (2020)
model7Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .0951461,
                          SE = .0319057,
                          Domain = "Ideological Groups")
# Values (2016) on Ideological Therms (2020)
model8Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .0208204,
                          SE = .0290482,
                          Domain = "Ideological Groups")
# Party Therms (2016) on Values (2020)
model9Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .114709,
                          SE = .0278572,
                          Domain = "Partisan Groups")
# Values (2016) on Party Therms (2020)
model10Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .0940248,
                          SE = .0291938,
                          Domain = "Partisan Groups")
# Candidate Therms (2016) on Values (2020)
model11Frame <- data.frame(Variable = "Affective Polarization",
                          Coefficient = .1558351,
                          SE = .0244001,
                          Domain = "Presidential Candidates")
# Values (2016) on Candidate Therms (2020)
model12Frame <- data.frame(Variable = "Value Extremity",
                          Coefficient = .0456672,
                          SE = .0268456,
                          Domain = "Presidential Candidates")

allModelFrame2 <- data.frame(rbind(model8Frame,model7Frame,model10Frame,model9Frame,model12Frame,model11Frame)) 

# Generate Plot
library(ggplot2)

interval2 <- -qnorm((1-0.95)/2) # set 95% CI

fig2 <- ggplot(allModelFrame2, aes(x = Domain, y = Coefficient, shape =  Variable))

fig2 <- fig2 + geom_hline(yintercept = 0, colour = gray(1/2), lty = 2)

fig2 <- fig2 + geom_pointrange(aes(x = Domain, y = Coefficient, ymin = Coefficient - SE*interval2, 
                                 ymax = Coefficient + SE*interval2), lwd = 1/2, position = position_dodge(width = 1/2))

fig2 <- fig2 + scale_shape_manual(name = "Lagged Variable", 
                                values = c(0,15)) 

fig2 <- fig2 + theme_bw() + theme(text=element_text(face="bold", size=12)) +
  theme(axis.title.x = element_blank()) + theme(legend.position="bottom")
fig2 <- fig2

fig2 <- fig2 + scale_y_continuous(breaks=seq(-.10, .25, .05),
                                limits=c(-.10, .25))

fig2


